import React, { useEffect, useState } from 'react';
import style from './CustomSwitch.css';

function CustomSwitch({ options, defaultChecked, onDispatch }){
    const [checked, setChecked] = useState(defaultChecked);
    return (
        <div className={style['flex-container']}>
            {
                options.map((item, index)=>(
                    <div className={style['flex-item'] + ' ' + (checked === index ? style['selected'] : '') } key={index} onClick={()=>setChecked(index)}>{ item }</div>
                ))
            }
        </div>
    )
}

export default CustomSwitch;